package com.pro.springbootshop.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pro.springbootshop.entity.ExtendOrders;
import com.pro.springbootshop.entity.Orders;
import org.apache.ibatis.annotations.*;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface ExtendOrdersMapper extends BaseMapper<ExtendOrders>{
    @Select("select max(orders_id) orders_id from extend_orders")
    Integer getMaxOrdersId();
    @Select("select * from extend_orders where orders_id = #{ordersId}")
    @Results(
            {
                    @Result(column = "extend_orders_id",property = "extendOrdersId"),
                    @Result(column = "orders_id",property = "ordersId"),
                    @Result(column = "order_id",property = "orderId"),
                    @Result(column = "order_id",property = "orders",javaType = Orders.class,
                            one=@One(select = "com.pro.springbootshop.mapper.OrderMapper.getOrdersByOrderId")
                    )
            }
    )
    List<ExtendOrders> selectOrderByOrdersId(Integer ordersId);
    @Select("select orders_id from extend_orders where order_id = #{orderId}")
    Integer getOrdersId(Integer orderId);
    @Select("select extend_orders_id from extend_orders where order_id = #{orderId}")
    Integer getExtendOrdersId(Integer orderId);

}
